﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GameSchool.Models.Repositories;

namespace GameSchool.Models.ViewModels
{
    public class NewsItemViewModel
    {
        public string Author { get; set; }
        public string Title { get; set; }
        public string Body { get; set; }
        public string Course { get; set; }
        public DateTime? date {get; set; }
        public int ID { get; set; }
        public bool? isTeacher { get; set; }

        public void parseCourseID(int? cID)
        {
            var rep = new CourseRepository();
            var cList = rep.GetCourses();
            
            Course = (from c in cList
                            where c.Key == cID
                            select c.Value).SingleOrDefault();
        }

        public void parseAuthorID(Guid? uID)
        {
            var rep = new UserRepository();
            var user = rep.GetUserProfileByID(uID);
            Author = user.Name;
        }

    }


}
